package com.carolouvindam;

import com.carolouvindam.Model.Product;

import java.util.ArrayList;
import java.util.List;

public abstract class Application {

    public static Product getCakeFromName(String name) {
        for (Product p : Application.CAKES) {
            if (p.getName().equals(name)) {
                return p;
            }

        }
        return null;
    }

    //Définit un tableau de produit par leur nom, leur IdDb, leur illustration, leur description
    public static final Product[] CAKES = new Product[]{
            new Product("Cake Flower Power", 0, R.drawable.cakeflowerpower, "Cake Flower Power : Delicious cake with flower taste"),
            new Product("ChocoCoulant", 1, R.drawable.chococoulant, "Chocolant : Cake with a hot creamy chocolate"),
            new Product("Defaut", 2, R.drawable.defaut, "Defaut : Ordinary cake"),
            new Product("GatoBonbon", 3, R.drawable.gatobonbon, "GatoBonbon : Sweet tasty cake with candies"),
            new Product("Gatokipik", 4, R.drawable.gatokipik, "Gatokipik : Be careful, this is a very spicy cake !"),
            new Product("Gatomagik", 5, R.drawable.gatomagik, "Gatomagik : A very Funky Cake"),
            new Product("Gatovanille", 6, R.drawable.gatovanille, "Gatovanille : Delicious soft vanilla taste cake"),
            new Product("Heinecake", 7, R.drawable.heinecake, "Heinecake : Perfect for a party, this is a beer cake !"),
            new Product("Meatcake", 8, R.drawable.meatcake, "Meatcake : Delicious cake with a meat taste"),
            new Product("Nian Cake", 9, R.drawable.niancake, "Nian Cake : A perfect cake for geek people"),
            new Product("Poetry Cake", 10, R.drawable.poetrycake, "Poetry Cake : Perfect cake to eat while you're reading a poem"),
            new Product("Tasty Cake", 11, R.drawable.tastycake, "Tasty Cake : Delicious cake with strong taste"),
            new Product("Wii Cake", 12, R.drawable.wiicake, "Wii Cake : Perfect cake to eat while you're playing Wii")
    };

    //Transforme le tableau de produits en liste de string
    public static List<String> getCakesList(Product[] cakes) {
        List<String> cakeList = new ArrayList<String>();
        for (Product cake : cakes) {
            cakeList.add(cake.getName());
        }
        return cakeList;
    }
}


